﻿@model IEnumerable<WebShop.Contracts.User>

@{
    ViewBag.Title = "Users Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            Actions
        </th>
        <th>
            UserName
        </th>
        <th>
            ContactName
        </th>
        <th>
            Role
        </th>
        <th>
            Email
        </th>
        <th>
            Comments
        </th>
        <th>
            CreatedDate
        </th>
        <th>
            LastLoginDate
        </th>
        <th>
            IsActivated
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.UserId }) |
            @Html.ActionLink("Details", "Details", new { id=item.UserId }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.UserId }) |
            @Html.ActionLink("View Activity", "Index", "Orders", new { userName = item.UserName }, null) |
            @Html.ActionLink("View Log", "Index", "Log", new { id = item.UserId })
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ContactName)
        </td>
        <td>
            <ul style="margin:0">
                @foreach (var role in item.Roles)
                {
                    <li>@role.RoleName</li>
                }
            </ul>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Comments)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CreatedDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastLoginDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IsActivated)
        </td>
    </tr>
}

</table>
